<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns="http://www.w3.org/1999/xhtml"
                template="./../WEB-INF/template/default.xhtml"
                xmlns:f="http://xmlns.jcp.org/jsf/core"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:p="http://primefaces.org/ui">

    <ui:define name="title">
        New Site
    </ui:define>

    <ui:define name="dialogs">

        <p:dialog>
            
        </p:dialog>
        
    </ui:define>

    <ui:define name="statusbar">

    </ui:define>

    <ui:define name="left">
        <p:layoutUnit position="west" size="300" collapsible="true" resizable="true" header="Common task" >
            <h:form>
                <p:menu style="width: 96%" >
                    <p:submenu label="About site">
                        <p:menuitem value="Find" icon="ui-icon-search" />
                        <p:menuitem value="New" icon="ui-icon-document" />
                        <p:menuitem value="Save" icon="ui-icon-disk" />
                        <p:menuitem value="Delete" icon="ui-icon-close" />
                    </p:submenu>
                    <p:submenu label="Actions">
                        <p:menuitem value="Add participant" icon="ui-icon-circle-plus" />
                        <p:menuitem value="Add intervention" icon="ui-icon-circle-plus" />
                        <p:menuitem value="Home" icon="ui-icon-home" action="dashboard.jsf?faces-redirect=true" />
                    </p:submenu>
                </p:menu>
            </h:form>
        </p:layoutUnit>
    </ui:define>

    <ui:define name="content">
        <f:facet name="header">
            <h:outputLabel value="New Site" styleClass="default-title-header" />
        </f:facet>
        <h:panelGrid columns="5">
            <h:outputLabel />
            <h:panelGroup>
                <h:panelGrid columns="3" >
                    <h:selectBooleanCheckbox value="#{siteBean.newProspective}" >
                        <h:outputLabel value="New Prospective"/>
                    </h:selectBooleanCheckbox>

                    <h:selectBooleanCheckbox value="#{siteBean.active}" >
                        <h:outputLabel value="Active"/>
                    </h:selectBooleanCheckbox>

                    <h:selectBooleanCheckbox value="#{siteBean.nonInterested}" >
                        <h:outputLabel value="Not interested"/>
                    </h:selectBooleanCheckbox>
                </h:panelGrid>
            </h:panelGroup>
            <h:outputLabel /><h:outputLabel /><h:outputLabel />

            <h:outputLabel value="Organization/Church Name" styleClass="default-label-size" />
            <h:panelGroup>
                <p:inputText id="txOrgChurch" required="true"
                             value="#{siteBean.current.orgname}"
                             requiredMessage="Organization/Church Name is required" />
                <p:message id="msgOrgChurch" for="txOrgChurch" />
            </h:panelGroup>
            <h:outputLabel />
            <h:outputLabel value="Website"/>
            <p:inputText value="#{siteBean.current.website}" />

            <h:outputLabel value="Organization Category"/>
            <h:panelGroup>
                <p:selectOneMenu id="lsCategory" value="#{siteBean.current.category.idcategory}" filter="true" filterMatchMode="startsWith" effect="fade"
                                 required="true" requiredMessage="Category is required" style="width: 150px" >
                    <f:selectItems value="#{siteBean.categories}" var="c" itemValue="#{c.idcategory}" itemLabel="#{c.categoryName}" />
                </p:selectOneMenu>
                <p:message for="lsCategory"/>
            </h:panelGroup>
            <h:outputLabel />
            <h:outputLabel value="Phone"/>
            <p:inputText value="#{siteBean.current.phone}" />

            <h:outputLabel value="State"/>
            <h:panelGroup>
                <p:selectOneMenu id="lsState" value="#{siteBean.idState}" filter="true" filterMatchMode="startsWith" effect="fade"
                                 required="true" requiredMessage="State is required" style="width: 150px" >
                    <f:selectItems value="#{siteBean.states}" var="state" itemValue="#{state.idstate}" itemLabel="#{state.statename}" />
                    <p:ajax listener="#{siteBean.onStateChange}" update="lsCity" />
                </p:selectOneMenu>
                <p:message id="msgLsState" for="lsState"/>
            </h:panelGroup>
            <h:outputLabel />
            <h:outputLabel value="City"/>
            <h:panelGroup>
                <p:selectOneMenu id="lsCity" value="#{siteBean.idCity}" filter="true" filterMatchMode="startsWith" effect="fade"
                                 required="true" requiredMessage="City is required" style="width: 150px" >
                    <f:selectItems value="#{siteBean.cities}" var="citi" itemValue="#{citi.idcity}" itemLabel="#{citi.cityname}" />
                </p:selectOneMenu>
                <p:message id="msgLsCity" for="lsCity" />
            </h:panelGroup> 

            <h:outputLabel value="Street"/> 
            <p:inputText value="#{siteBean.current.street}" />
            <h:outputLabel />
            <h:outputLabel value="Zip code"/>          
            <p:inputText value="#{siteBean.current.zipcode}" />
        </h:panelGrid>

        <h3>Site Contact Information</h3>
        <h:panelGrid columns="2">
            <h:outputLabel value="Tentative Facilitator" styleClass="default-label-size" />
            <p:inputText value="#{siteBean.current.tentativefac}" styleClass="default-large-inputtext" />

            <h:outputLabel value="Facilitator Phone"/>
            <p:inputText value="#{siteBean.current.facilitatorphone}" 
                         styleClass="default-large-inputtext" />

            <h:outputLabel value="Facilitator email"/>
            <p:inputText value="#{siteBean.current.facilitatormail}" 
                         styleClass="default-large-inputtext" />
        </h:panelGrid>

        <h3>Site Intervention Leads</h3>
        <h:panelGrid columns="2">
            <h:outputLabel styleClass="default-label-size"/>
            <h:panelGroup>
                <h:outputLabel value="TPP Grant MOU"/>
                <h:selectBooleanCheckbox value="#{siteBean.tppGrantMou}" styleClass="label-checkbox inline" />

                <h:outputLabel value="Pastor/Leader MOU"/>    
                <h:selectBooleanCheckbox value="#{siteBean.pastorLeaderMou}" styleClass="label-checkbox inline" />
            </h:panelGroup>
            <h:outputLabel value="Estimated youth"/>
            <h:panelGroup>
                <p:inputText id="txYouth" value="#{siteBean.current.youth}" 
                             converterMessage="Estimated youth should be a number" >
                    <f:convertNumber integerOnly="true" type="number" />
                </p:inputText>
                <p:message id="msgYouth" for="txYouth" />
            </h:panelGroup>
        </h:panelGrid>

        <h3>Training Status</h3>
        <h:panelGrid columns="2">
            <h:outputLabel value="Registered for Training" styleClass="default-label-size"/>
            <h:selectBooleanCheckbox value="#{siteBean.registeredForTraining}" />

            <h:outputLabel value="# of Attendees (Reg. Training)"/>
            <h:panelGroup>
                <p:inputText id="txNumberOfAtt" value="#{siteBean.current.attendess}"
                             converterMessage="# of Attendees should be a number" >
                    <f:convertNumber integerOnly="true" type="number" />
                </p:inputText>
                <p:message id="msgNumberOfAtt" for="txNumberOfAtt" />
            </h:panelGroup>

            <h:outputLabel value="Notes"/>
            <p:inputTextarea value="#{siteBean.current.notes}" styleClass="default-large-inputtext" rows="5" />
        </h:panelGrid>
    </ui:define>

</ui:composition>
